package cn.ltgodm.moj.judge.codesandbox;

import cn.ltgodm.moj.judge.codesandbox.impl.ExampleCodeSandbox;
import cn.ltgodm.moj.judge.codesandbox.impl.RemoteCodeSandbox;
import cn.ltgodm.moj.judge.codesandbox.impl.ThirdPartyCodeSandbox;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * 代码沙箱工厂
 */
@Configuration
public class CodeSandboxFactory {

    @Resource
    private RemoteCodeSandbox remoteCodeSandbox;
    @Resource
    private ExampleCodeSandbox exampleCodeSandbox;
    @Resource
    private ThirdPartyCodeSandbox thirdPartyCodeSandbox;

    public  CodeSandbox getSandBox(String type) {
        switch (type) {
            case "example":
                return exampleCodeSandbox;
            case "remote":
                return remoteCodeSandbox;
            case "thirdParty":
                return thirdPartyCodeSandbox;
            default:
                return exampleCodeSandbox;
        }
    }
}
